﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace MoodLaZik
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private List<String> _moodList = new List<string>() { "HAPPY", "SAD", "SLEEPY", "FUNKY", "DRIVING",
            "WORKING", "MELANCHOLY", "NOSTALGY", "AGGRESSIVE", "SUICIDAL", "ROMANTIC", "CHILLOUT", "CALM" };
        private List<String> _placeList = new List<string>() {"HOME", "SUBWAY", "WORK", "GYM ROOM", "SCHOOL",
            "ON ROAD", "OUTSIDE" };
        private List<String> _weatherList = new List<string>() { "SUNNY", "RAINY", "CLOUDY", "FOGGY", "STORMY" };
        private List<String> _envList = new List<string>() { "SILENT", "NOISY", "CALM", "SPIRITUAL","FAMILIAL", "URBAN" };
        private List<String> _personnalityList = new List<string>() { "AGGRESSIVE", "SUICIDAL", "INTROVERTED", "EXTRAVERTED" };
		private List<Int32> _markList = new List<Int32>() { 0, 1, 2, 3, 4, 5 };

        public MainWindow()
        {
			this.InitializeComponent();
			this.initMoods();
			this.initPlaces();
			this.initWeather();
			this.initEnv();
			this.initPersonnality();
			this.initMarks();
			//mediaElement1.ScrubbingEnabled = true;
        }

        private void initWeather()
        {
            foreach (string s in _weatherList.OrderBy(s=>s))
                Weather_CB.Items.Add(s);
            Weather_CB.SelectedValue = _weatherList[0];
        }

        private void initEnv()
        {
            foreach (string s in _envList.OrderBy(s=>s))
                Environment_CB.Items.Add(s);
            Environment_CB.SelectedValue = _envList[0];
        }

        private void initPersonnality()
        {
            foreach (string s in _personnalityList.OrderBy(s=>s))
                Personnality_CB.Items.Add(s);
            Personnality_CB.SelectedValue = _personnalityList[0];
        }
        
        private void initMoods()
        {
            foreach (string s in _moodList.OrderBy(s=>s))
                Mood_CB.Items.Add(s);
            Mood_CB.SelectedValue = _moodList[0];
        }
        
        private void initPlaces()
        {
            foreach (string s in _placeList.OrderBy(s => s))
                Place_CB.Items.Add(s);
            Place_CB.SelectedValue = _placeList[0];
        }

		private void initMarks()
		{
			foreach (Int32 i in _markList.OrderBy(s => s))
			{
				Mark_CB.Items.Add(i);
				giveMark_CB.Items.Add(i);
			}
			Mark_CB.SelectedValue = 3;
			giveMark_CB.SelectedValue = 5;
		}

		private void Element_MediaEnded(object sender, EventArgs e)
		{
		}

		private void SeekToMediaPosition(object sender, RoutedPropertyChangedEventArgs<double> args)
		{
			double SliderValue = slider1.Value;
			if (mediaElement1.Position.TotalSeconds - SliderValue < -2
				|| mediaElement1.Position.TotalSeconds - SliderValue > 2)
			{
				TimeSpan ts = TimeSpan.FromSeconds(SliderValue);
				mediaElement1.Position = ts;
				//mediaElement1.Clock.Controller.Seek(TimeSpan.FromSeconds(SliderValue), TimeSeekOrigin.BeginTime);
			}
		}
    }
}
